$('.login-btn').click(function(){
    // console.log(1);
    var str = $('.user').val()
    var pwd = $('.pass').val()
    var type = 0;
    if($('.checkbox').is(':checked')){
        type = 1
    }
    // console.log(type);
    // console.log(str);
    var reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
    if(reg.test(str)){
        $('.dis').addClass('hide')

        $.ajax({
            url:'./php/login.php',
            type:'POST',
            data:`user=${str}&pwd=${pwd}&type=${type}`,
            dataType:'json',
            success:function(data){
                if(data['code']==1){
                    $('.erro').addClass('hide')
                    alert('登录成功，即将跳转主页页面')
                    window.location.href = './index.html'
                }else{
                    $('.erro').removeClass('hide')
                }
            }
        })
    }else{
        $('.dis').removeClass('hide')
    }
})
let cname = getCookie('uname');
let cpwd = getCookie('upass');
if(cname != undefined){
    $('.user').val(cname)
}
if(cpwd!=undefined){
    $('.pass').val(cpwd)
    $('.checkbox').attr('checked',true)
}else{
    $('.checkbox').removeAttr('checked');
}